{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['https://static.vmgirls.com/image/2019/10/F9A91867-194B-4F18-90CF-65CE2A8BFDDA.jpeg', 'https://static.vmgirls.com/image/2019/10/C7CB2605-6B1A-4BCB-B830-2BA84F47CCC0.jpeg', 'https://static.vmgirls.com/image/2019/10/D98031A3-7297-43A7-BBEC-482EF5B91966.jpeg', 'https://static.vmgirls.com/image/2019/10/7784F504-2B9A-4116-8E43-DCCEB1DF0A4A.jpeg', 'https://static.vmgirls.com/image/2019/10/FDBE6A1F-E526-4A2D-9100-53155F043A93.jpeg', 'https://static.vmgirls.com/image/2019/10/D5999731-4602-4761-AB5E-B52C1110A2C7.jpeg', 'https://static.vmgirls.com/image/2019/10/2A423460-4B6F-4D95-BD6E-14D7AFC335E5.jpeg', 'https://static.vmgirls.com/image/2019/10/5377AD7A-3019-49C7-BA20-43EFD6B90D2E.jpeg', 'https://static.vmgirls.com/image/2019/10/385C1DBC-9564-4782-A90D-4263E323A0ED.jpeg', 'https://static.vmgirls.com/image/2019/10/2AD92837-7BFC-4BA1-BA28-88920850852F.jpeg', 'https://static.vmgirls.com/image/2019/10/1385185F-78D2-4933-9A0D-06CB8EB32C80.jpeg', 'https://static.vmgirls.com/image/2019/10/1597CDCB-9701-48D9-BD43-8EBD753FBB88.jpeg', 'https://static.vmgirls.com/image/2019/10/7E3BC69C-1ADB-49CE-8250-F089DCF078C6.jpeg']\n"
     ]
    }
   ],
   "source": [
    "import re\n",
    "import requests\n",
    "import os\n",
    "import time\n",
    "from fake_useragent import UserAgent\n",
    "\n",
    "useragent=UserAgent().chrome\n",
    "headers={\n",
    "    'User-Agent':useragent\n",
    "}\n",
    "dirname=\"美女\"\n",
    "if not os.path.exists(dirname):\n",
    "    os.mkdir(dirname)\n",
    "url='https://www.vmgirls.com/12945.html'\n",
    "res=requests.get(url,headers=headers)\n",
    "res.encoding='utf-8'\n",
    "resone=re.findall('<a href=\"(.*?)\" alt=\".*?\" title=\".*?\">',res.text)\n",
    "\n",
    "print(resone)\n",
    "\n",
    "for i in resone:\n",
    "    time.sleep(1)\n",
    "    filename=i.split('/')[-1]\n",
    "    response=requests.get(i,headers=headers)\n",
    "    with open(dirname+'/'+filename,'wb') as f:\n",
    "        f.write(response.content)\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
